<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>鼠标移动事件</title>
    <style>
        .box {
            width: 200px;
            height: 200px;
            background-color: orange;
        }
        
        .box1 {
            width: 100px;
            height: 100px;
            background-color: black;
        }
    </style>
</head>

<body>
    <div class="box">
        <div class="box1">

        </div>
    </div>
    <script src="demo/Todolist/js/utils.js"></script>
    <script>
        // 鼠标滑入滑出 mouseover mouseout
        // 对设置mouseover mouseout的所有子元素移入移除都生效
        var oBox = document.getElementsByClassName('box')[0],
            oBox1 = document.getElementsByClassName('box1')[0],
            overCount = 0,
            outCount = 0;
        // oBox.onmouseover = function() {
        //     this.style.backgroundColor = 'green'
        // }
        // oBox.onmouseout = function() {
        //     this.style.backgroundColor = 'white'
        // }
        // oBox1.onmouseover = function() {
        //     cancelBubble(e)
        //     this.style.backgroundColor = 'black'
        // }
        // oBox1.onmouseout = function() {
        //     cancelBubble(e)
        //     this.style.backgroundColor = 'white'
        // }
        // oBox.onmouseover = function () {
        //     overCount++
        //     console.log('overCount' + overCount);
        // }
        // oBox.onmouseout = function () {
        //     outCount++;
        //     console.log('outCount' + outCount);
        // }

        //mouseenter mouseleave
        //    只对绑定的元素生效
        oBox.onmouseenter = function() {
            overCount++
            console.log('overCount' + overCount);
        }
        oBox.onmouseleave = function() {
            outCount++;
            console.log('outCount' + outCount);
        }
    </script>
</body>

</html>